New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

indicative-compiler

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indicative-compiler

Indicative compiler to compile parsed schema into highly optimized functions

  • 7.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
increased by29.17%
Maintainers
1
Weekly downloads
 
Created
Source

Indicative Compiler

circleci-image npm-image license-image

Indicative compiler to compile validations schema into a highly optimized executable function.

Indicative is a highly performant validation library for Node.js. It achieves this by compiling the schema into a tree and then an a top level executable function.

Table of contents

Usage

Install the package from npm registry as follows:

You must use indicative directly. This is a low level module meant to be used by indicative itself.

npm i indicative-compiler

# yarn
yarn add indicative-compiler

and then use it as follows:

import { ValidatorCompiler, ValidatorExecutor } from 'indicative-compiler'
import { VanillaFormatter } from 'indicative-formatters'
import * as validations from 'indicative-rules'

const schema = {
  username: 'required',
  email: 'required|email'
}

const messages = {}

// Do it once for each schema
const compiledFunctions = new ValidatorCompiler(schema, messages).compile()

await new ValidatorExecutor(compiledFunctions).exec(data, VanillaFormatter, {}, false, false)

The ValidatorExecutor.exec function takes 5 parameters.

  1. data: The runtime data to validate against the compiled schema.
  2. formatter: Formatter constructor to collect and format error messages.
  3. config: The config to be passed to all the validation functions.
  4. bail: When true, it will stop after first error.
  5. removeAdditional: When true, the exec will return only validated properties.

API Docs

Following are the autogenerated files via Typedoc

Keywords

FAQs

Package last updated on 25 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc